package com.gexiaobao.pigeon.ui.fragment.setting.pattern;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

import com.gexiaobao.pigeon.app.App;


/**
 * Created by babosa on 14/10/2017.
 */


public class PatternSharedPreferencesUtil {
    private static PatternSharedPreferencesUtil instance;

    private SharedPreferences.Editor editor;
    private static SharedPreferences prefer;

    public static void PatternSharedPreferencesUtilInit(Context context) {
        prefer = PreferenceManager.getDefaultSharedPreferences(context);
    }

    public PatternSharedPreferencesUtil() {
        this.prefer = PreferenceManager.getDefaultSharedPreferences(App.instance);
        this.editor = prefer.edit();
    }

    public static PatternSharedPreferencesUtil getInstance() {
        if (instance == null) {
            synchronized (PatternSharedPreferencesUtil.class) {
                if (instance == null) {
                    instance = new PatternSharedPreferencesUtil();
                }
            }
        }

        return instance;
    }

    public void saveString(String name, String data) {
        this.editor.putString(name, data);
        this.editor.commit();
    }

    public String getString(String name) {
        return prefer.getString(name, null);
    }
}
